
layui.config({
	base: basePath, 
	version: skyeyeVersion
}).extend({
    window: 'js/winui.window'
}).define(['window', 'jquery', 'winui'], function (exports) {
	winui.renderColor();
	layui.use(['form'], function (form) {
		var index = parent.layer.getFrameIndex(window.name);
	    var $ = layui.$;

		var wagesFieldTypeListHtml = '';
		AjaxPostUtil.request({url: sysMainMation.wagesBasePath + "queryEnableWagesFieldTypeList", params: {}, type: 'json', method: "POST", callback: function (json) {
			wagesFieldTypeListHtml = getDataUseHandlebars(`<option value="">全部</option>{{#each rows}}<option value="{{id}}">{{name}}({{id}})</option>{{/each}}`, json);
		}, async: false});

		skyeyeClassEnumUtil.showEnumDataListByClassName("commonEnable", 'radio', "enabled", '', form);
		initTable();
		matchingLanguage();
 		form.render();
 	    form.on('submit(formAddBean)', function (data) {
 	        if (winui.verifyForm(data.elem)) {
				var result = initTableChooseUtil.getDataList('fieldList');
				if (!result.checkResult) {
					return false;
				}
				var tableData = [].concat(result.dataList);
				var params = {
					name: $("#name").val(),
					jobId: parent.jobId,
					enabled: $("#enabled input:radio:checked").val(),
					scoreFields: JSON.stringify(tableData)
 	        	};
 	        	AjaxPostUtil.request({url: reqBasePath + "writeCompanyJobScoreMation", params: params, type: 'json', method: 'POST', callback: function (json) {
					parent.layer.close(index);
					parent.refreshCode = '0';
 	        	}});
 	        }
 	        return false;
 	    });

		function initTable() {
			initTableChooseUtil.initTable({
				id: "fieldList",
				cols: [
					{id: 'fieldKey', title: '字段', formType: 'select', width: '150', verify: 'required', modelHtml: wagesFieldTypeListHtml},
					{id: 'minMoney', title: '最小薪资范围', formType: 'input', width: '100', verify: 'required|money', value: '0'},
					{id: 'maxMoney', title: '最大薪资范围', formType: 'input', width: '100', verify: 'required|money', value: '0'},
					{id: 'remark', title: '备注', formType: 'input', width: '100'}
				],
				deleteRowCallback: function (trcusid) {
				},
				addRowCallback: function (trcusid) {
				},
				form: form
			});
		}

	    $("body").on("click", "#cancle", function() {
	    	parent.layer.close(index);
	    });
	});
});